var g = require('graphql');
var graphql = require('graphql').graphql;
var GraphQLSchema = g.GraphQLSchema;
var GraphQLObjectType = g.GraphQLObjectType;
var GraphQLString = g.GraphQLString;

var Type = new GraphQLObjectType({
   name: 'TestType',
   fields: () => ({
     a: { 
       type: GraphQLString,
       resolve: (context) => {
         console.log('resolving a')
           throw {
             code: 3342,
             message: 'world'
           }
       }
     },
     b: { type: GraphQLString },
     t: {
       type: Type,
       resolve: (context) => {
         console.log('calling resolve deep');
         return {a: 'x-', b: 'ee'};
       }
     },
     y: {
       type: Type,
       resolve: (context) => {
         console.log('calling resolve deep');
         return {a: 'x-', b: 'ee'};
       }
     },
   })
 })
const schema = new GraphQLSchema({
 query: Type,
});

const data = {
 a() { return 'a'; },
 b() { return 'b'; }
};

var qs = `
query  { 
  a 
  t { ... Dog  }
  y { ... Dog  }
}

fragment Dog on TestType {
  b
}
`

graphql(schema, qs, data).then(function(res) {
 console.log('t-error', res.errors);
}).catch(e => console.log(e));
